/**
 * @description: 防抖函数（指令）
 * @return {*}
 */
export const vDebounce = {
    mounted(el, binding) {
        const [fn, event = 'keyup', time = 300] = binding.value;
        let timer;
        el.addEventListener(event, () => {
            timer && clearTimeout(timer);
            // eslint-disable-next-line
            timer = setTimeout(() => fn.apply(null, arguments), time);
        });
    },
    beforeMount(el, binding) {
        const [fn, event = 'keyup'] = binding.value;
        el.removeEventListener(event, fn);
    }
};
